package org.ISCS.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.ISCS.entity.Project;
import org.ISCS.entity.customize.CustomResult;
import org.ISCS.service.ProjectService;
import org.ISCS.mapper.ProjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author mj
* @description 针对表【project】的数据库操作Service实现
* @createDate 2023-05-23 10:11:20
*/
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project>
    implements ProjectService{

    @Autowired
    ProjectMapper projectMapper;
    @Override
    public CustomResult getProjectByName(String projectName) {
        CustomResult result;
        Project project = (Project) projectMapper.selectAllByProjectName(projectName);
        if (project == null){
            result = new CustomResult(40000,"find null",null);
        }else {
            result = new CustomResult(20000,"Success",project);
        }
        return result;
    }

    @Override
    public CustomResult updateProject(Project project) {
        CustomResult result;
        int tmp = projectMapper.updateSelective(project);
        if (tmp > 0){
            result = new CustomResult(20000,"Success",null);
        }else {
            result = new CustomResult(40000,"Failed",null);
        }
        return result;
    }

    @Override
    public CustomResult insertProject(Project project) {
        CustomResult result;
        int tmp = projectMapper.insertSelective(project);
        if (tmp > 0){
            result = new CustomResult(20000,"Success",null);
        }else {
            result = new CustomResult(40000,"Failed",null);
        }
        return result;
    }

}




